#ifndef HMS_BC_ORTHO_DISCHARGE_VELOCITY_HPP
#define HMS_BC_ORTHO_DISCHARGE_VELOCITY_HPP

#include "boundaryCondition.hpp"
#include "cubicRoot.hpp"
#include "coordTransformer.hpp"
#include "fieldMemberMacros.hpp"

namespace hms
{

template<typename MeshType>
class OrthogonalDischarge_velocity : public BoundaryCondition<MeshType>
{
public:
	using BaseType = BoundaryCondition<MeshType>;
	using Type = typename BaseType::Type;
	using BaseType::field;
	using BaseType::patch;

private: 
	static constexpr Index bufCols { cubic::norm_noLin::bufCols + 1 };
	scalar m_qBoundary;

	mutable ArrayXNs<bufCols> m_calcBuf;

	FieldTransformer<MeshType> m_transformer;

	mutable std::experimental::observer_ptr<Field<MeshType>> m_dField {nullptr};

public:
	OrthogonalDischarge_velocity() = default;

	OrthogonalDischarge_velocity(
		Field<MeshType>& vField,
		const BoundaryPatch&,
		Field<MeshType>& dField,
		scalar qBoundary
	);

	virtual void update() const override;

	auto qBoundary() const -> scalar;
	void qBoundary(scalar);

	auto dField() const -> Field<MeshType>&;
	void dField( Field<MeshType>& );

};

} // namespace hms

#endif